﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;

namespace DataTier
{
    [KnownType(typeof(SubscriptionType))]
    [KnownType(typeof(CarModel))]
    [KnownType(typeof(Booking))]
    [KnownType(typeof(Battery))]
    [DataContract(IsReference = true)]
    public class Subscription
    {
        private SubscriptionType _subscriptionType;
        private CarModel _carModel;
        private List<Booking> _bookings;
        private int _subscriptionId;
        private Battery _battery;
        private int _carId;
        private Customer _customer;

        #region Constructors

        public Subscription(int subscriptionId, SubscriptionType subscriptionType, CarModel carModel)
        {
            this._subscriptionId = subscriptionId;
            this._subscriptionType = subscriptionType;
            this._carModel = carModel;
            _bookings = new List<Booking>();
        }

        public Subscription(int id, string stName, string cmDesc)
        {
            this._subscriptionId = id;
            SubscriptionType s = new SubscriptionType(stName);
            CarModel c = new CarModel(cmDesc);
            this._subscriptionType = s;
            this._carModel = c;
        }

        public Subscription(int sid, int stid, int carid, int batid, int cid, int cmid)
        {
            this._subscriptionId = sid;
            SubscriptionType s1 = new SubscriptionType(stid);
            this._subscriptionType = s1;
            CarModel c1 = new CarModel(cmid);
            this._carModel = c1;
            Battery b1 = new Battery(batid);
            this._battery = b1;
            this._carId = carid;

        }

        public Subscription(int cId, int sId)
        {
            this.SubscriptionId = sId;
            _customer = new Customer(cId);
        }

        public Subscription(int sId)
        {
            this._subscriptionId = sId;
        }



        public Subscription()
        { }

        #endregion

        #region Properties

        [DataMember]
        public int SubscriptionId
        {
            get { return _subscriptionId; }
            set { _subscriptionId = value; }
        }

        [DataMember]
        public int CarId
        {
            get { return _carId; }
            set { _carId = value; }
        }

        [DataMember]
        public SubscriptionType SubscriptionType
        {
            get { return _subscriptionType; }
            set { _subscriptionType = value; }
        }

        [DataMember]
        public string SubscriptionTypeName
        {
            get { return _subscriptionType.Name; }
            set { _subscriptionType.Name = value; }
        }

        [DataMember]
        public string CarModelName
        {
            get { return _carModel.Description; }
            set { _carModel.Description = value; }
        }

        [DataMember]
        public Battery Battery
        {
            get { return _battery; }
            set { _battery = value; }
        }

        [DataMember]
        public CarModel CarModel
        {
            get { return _carModel; }
            set { _carModel = value; }
        }

        [DataMember]
        public Customer Customer
        {
            get { return _customer; }
            set { _customer = value; }
        }


        #endregion

        
    }
}
